/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.shoppingsystem.model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Victor Cifuentes (victor.cifuentes@correounivalle.edu.co)
 */
@Entity
@Table(name = "pago_tarjeta")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PagoTarjeta.findAll", query = "SELECT p FROM PagoTarjeta p"),
    @NamedQuery(name = "PagoTarjeta.findById", query = "SELECT p FROM PagoTarjeta p WHERE p.id = :id"),
    @NamedQuery(name = "PagoTarjeta.findByBanco", query = "SELECT p FROM PagoTarjeta p WHERE p.banco = :banco"),
    @NamedQuery(name = "PagoTarjeta.findByTipoCuenta", query = "SELECT p FROM PagoTarjeta p WHERE p.tipoCuenta = :tipoCuenta"),
    @NamedQuery(name = "PagoTarjeta.findByNumeroCuenta", query = "SELECT p FROM PagoTarjeta p WHERE p.numeroCuenta = :numeroCuenta"),
    @NamedQuery(name = "PagoTarjeta.findByComprobacion", query = "SELECT p FROM PagoTarjeta p WHERE p.comprobacion = :comprobacion"),
    @NamedQuery(name = "PagoTarjeta.findByCuotas", query = "SELECT p FROM PagoTarjeta p WHERE p.cuotas = :cuotas"),
    @NamedQuery(name = "PagoTarjeta.findByTotal", query = "SELECT p FROM PagoTarjeta p WHERE p.total = :total")})
public class PagoTarjeta implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    private Integer id;
    @Basic(optional = false)
    @Column(name = "banco", nullable = false, length = 45)
    private String banco;
    @Basic(optional = false)
    @Column(name = "tipo_cuenta", nullable = false, length = 45)
    private String tipoCuenta;
    @Basic(optional = false)
    @Column(name = "numero_cuenta", nullable = false, length = 45)
    private String numeroCuenta;
    @Basic(optional = false)
    @Column(name = "comprobacion", nullable = false, length = 45)
    private String comprobacion;
    @Column(name = "cuotas")
    private Integer cuotas;
    @Basic(optional = false)
    @Column(name = "total", nullable = false)
    private int total;
    @JoinColumn(name = "factura_id", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private Factura facturaId;

    public PagoTarjeta() {
    }

    public PagoTarjeta(Integer id) {
        this.id = id;
    }

    public PagoTarjeta(Integer id, String banco, String tipoCuenta, String numeroCuenta, String comprobacion, int total) {
        this.id = id;
        this.banco = banco;
        this.tipoCuenta = tipoCuenta;
        this.numeroCuenta = numeroCuenta;
        this.comprobacion = comprobacion;
        this.total = total;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        Integer oldId = this.id;
        this.id = id;
        changeSupport.firePropertyChange("id", oldId, id);
    }

    public String getBanco() {
        return banco;
    }

    public void setBanco(String banco) {
        String oldBanco = this.banco;
        this.banco = banco;
        changeSupport.firePropertyChange("banco", oldBanco, banco);
    }

    public String getTipoCuenta() {
        return tipoCuenta;
    }

    public void setTipoCuenta(String tipoCuenta) {
        String oldTipoCuenta = this.tipoCuenta;
        this.tipoCuenta = tipoCuenta;
        changeSupport.firePropertyChange("tipoCuenta", oldTipoCuenta, tipoCuenta);
    }

    public String getNumeroCuenta() {
        return numeroCuenta;
    }

    public void setNumeroCuenta(String numeroCuenta) {
        String oldNumeroCuenta = this.numeroCuenta;
        this.numeroCuenta = numeroCuenta;
        changeSupport.firePropertyChange("numeroCuenta", oldNumeroCuenta, numeroCuenta);
    }

    public String getComprobacion() {
        return comprobacion;
    }

    public void setComprobacion(String comprobacion) {
        String oldComprobacion = this.comprobacion;
        this.comprobacion = comprobacion;
        changeSupport.firePropertyChange("comprobacion", oldComprobacion, comprobacion);
    }

    public Integer getCuotas() {
        return cuotas;
    }

    public void setCuotas(Integer cuotas) {
        Integer oldCuotas = this.cuotas;
        this.cuotas = cuotas;
        changeSupport.firePropertyChange("cuotas", oldCuotas, cuotas);
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        int oldTotal = this.total;
        this.total = total;
        changeSupport.firePropertyChange("total", oldTotal, total);
    }

    public Factura getFacturaId() {
        return facturaId;
    }

    public void setFacturaId(Factura facturaId) {
        Factura oldFacturaId = this.facturaId;
        this.facturaId = facturaId;
        changeSupport.firePropertyChange("facturaId", oldFacturaId, facturaId);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PagoTarjeta)) {
            return false;
        }
        PagoTarjeta other = (PagoTarjeta) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.shoppingsystem.model.PagoTarjeta[ id=" + id + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
